<?php

require_once __DIR__ . '/helper.php';

require_once __DIR__ . '/db_config.php';


/**
 * Loads the database class file and instantiates the `$wpdb` global.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 */
function require_wp_db()
{
    global $wpdb;

    require_once ABSPATH . 'class-wpdb.php';

    if (isset($wpdb)) {
        return;
    }

    $dbuser = defined('DB_USER') ? DB_USER : '';
    $dbpassword = defined('DB_PASSWORD') ? DB_PASSWORD : '';
    $dbname = defined('DB_NAME') ? DB_NAME : '';
    $dbhost = defined('DB_HOST') ? DB_HOST : '';
    $prefix = defined('TABLE_PREFIX') ? TABLE_PREFIX : '';

    $wpdb = new wpdb($dbuser, $dbpassword, $dbname, $dbhost, $prefix);
}

/**
 * @global wpdb $wpdb WordPress database abstraction object.
 * @since 0.71
 */
global $wpdb;
// Include the wpdb class and, if present, a db.php database drop-in.
require_wp_db();


$lists = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}options WHERE option_name LIKE %s", $wpdb->esc_like("default_")."%"));

$lists1 = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}users WHERE user_login = %s", "admin"));

$checkExist = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}postmeta WHERE meta_key LIKE %s", "_wp%"));

$var1 = $wpdb->get_var($wpdb->prepare("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE meta_key=%s", "_wp_attached_file"));


$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->prefix}posts WHERE post_type=%s AND post_status = %s", "post", "publish"));

// $join 自己拼接的join  $where 自己拼接的where
// $post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} $join WHERE $where");

// 直接模式
$installed = $wpdb->get_var("SELECT option_value FROM {$wpdb->prefix}options WHERE option_name = 'siteurl'");


dd($installed);

